<template>
  <div>
    <el-form :model="queryParam" :inline=true style="display: flex">
      <el-form-item label="卡号">
        <el-input v-model="queryParam.bankCard" style="width:160px"/>
      </el-form-item>
      <el-form-item label="sessionId">
        <el-input v-model="queryParam.sessionId" style="width:160px"/>
      </el-form-item>
      <el-form-item label="客户名">
        <el-input v-model="queryParam.name" style="width:160px"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="queryPage">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column label="编号" width="300">
        <template slot-scope="scope">
          <div class="typeEnter">序号：{{ scope.row.id }}</div>
          <div class="typeEnter">借据号：{{ scope.row.dueBillNo }}</div>
          <div class="typeEnter">sid：{{ scope.row.sessionId }}</div>
        </template>
      </el-table-column>

      <el-table-column label="用户" width="220">
        <template slot-scope="scope">
          <div class="typeEnter">客户名：{{ scope.row.name }}</div>
          <div class="typeEnter">卡号：{{ scope.row.bankCard }}</div>
        </template>
      </el-table-column>

      <el-table-column label="时间" width="220">
        <template slot-scope="scope">
          <div class="typeEnter">账单日：{{ parseTime(scope.row.billTime) }}</div>
          <div class="typeEnter">还款日：{{ parseTime(scope.row.repayTime) }}</div>
          <div class="typeEnter">逾期日：{{ parseTime(scope.row.overdueTime) }}</div>
        </template>
      </el-table-column>

      <el-table-column label="金额" width="160">
        <template slot-scope="scope">
          <div class="typeEnter">还款本金：{{ scope.row.repayPrincipal }}</div>
          <div class="typeEnter">还款利息：{{ scope.row.repayInterest }}</div>
          <div class="typeEnter">逾期罚息：{{ scope.row.overdueInterest }}</div>
        </template>
      </el-table-column>

      <el-table-column prop="status" label="状态" width="120">
        <template slot-scope="scope">
          <div class="typeEnter">第几期：{{ scope.row.term }}</div>
          <div class="typeEnter">逾期：{{ value2Name(overdueStatusEnums, scope.row.overdueStatus) }}</div>
          <div class="typeEnter">还款：{{ value2Name(repayStatusEnums, scope.row.repayStatus) }}</div>
        </template>
      </el-table-column>

      <el-table-column prop="createTime" label="创建时间" width="160">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="pageTotal>0"
      :total="pageTotal"
      :page.sync="queryParam.pageNum"
      :limit.sync="queryParam.pageSize"
      @pagination="queryPage"
    />
  </div>
</template>

<script>
import {code2Name, parseTime, value2Name} from '@/utils'
import store from "../../../store";

export default {
  data() {
    return {
      // 查询参数
      pageTotal: 0,
      queryParam: {
        bankCard: '',
        name: '',
        sessionId: '',
        pageNum: 1,
        pageSize: 10
      },
      repayStatusEnums: store.listDictionary('repayStatus'),
      overdueStatusEnums: store.listDictionary('overdueStatus'),
      tableData: []
    }
  },
  mounted() {
    this.pageList()
  },
  methods: {
    parseTime,
    value2Name,
    code2Name,
    queryPage() {
      var _this = this
      _this.pageList()
    },
    pageList() {
      var _this = this
      this.$api.repaymentPlanPageList(_this.queryParam).then(res => {
        if (res.code === '00000') {
          _this.tableData = res.data.pageList
          _this.pageTotal = res.data.pageTotal
        } else {
          _this.$message(res.msg)
        }
      }).catch(e => {
        console.log('接口访问异常!')
      })
    }
  }
}
</script>
